package edu.ynu.se.xiecheng.achitectureclass.dao;

import edu.ynu.se.xiecheng.achitectureclass.common.dao.LogicDAO;
import edu.ynu.se.xiecheng.achitectureclass.entity.CameraData;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.util.Date;
import java.util.List;

@Repository
public interface CameraDataDao extends JpaRepository<CameraData, Long>, LogicDAO<CameraData, Long> {
    
    /**
     * 查询指定时间范围内的照片，按时间倒序排列
     */
    List<CameraData> findByCreateTimeBetweenAndIsDeletedOrderByCreateTimeDesc(
        Date start, 
        Date end, 
        Integer isDeleted,
        Pageable pageable
    );

    /**
     * 统计指定时间范围内的照片数量
     */
    long countByCreateTimeBetweenAndIsDeleted(Date start, Date end, Integer isDeleted);

    /**
     * 查询最近的照片
     */
    List<CameraData> findByDeviceIdAndIsDeletedOrderByCreateTimeDesc(Long deviceId, Integer isDeleted, Pageable pageable);
}